import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {
  JdPurchaseEnterWarehouseOrderVO,
  JdPurchaseEnterWarehouseOrderForm,
  JdPurchaseEnterWarehouseOrderQuery
} from '@/api/jdAndJstSceneClassification/purchasingProcess/jdPurchaseEnterWarehouseOrder/types';
import { listPurchaseEnterWarhouseOrderByDongGuanAndGuoNei } from 'src/api/jdAndJstSceneClassification/purchasingProcess/jstPurchaseEnterWarehouseOrder';

/**
 * 查询金蝶-采购入库单列表
 * @param query
 * @returns {*}
 */

export const listJdPurchaseEnterWarehouseOrder = (query?: JdPurchaseEnterWarehouseOrderQuery): AxiosPromise<JdPurchaseEnterWarehouseOrderVO[]> => {
  return request({
    url: '/dataCheck/jd/purchaseEnterWarehouseOrder/list',
    method: 'get',
    params: query
  });
};

/**
 * 01、定义后端接口
 * 查询金蝶-采购入库单列表
 * 业务查询条件：根据warehouseName仓库名称为东莞仓和国内在途仓查询
 * @param query
 * @returns {*}
 */

export const listJdPurchaseEnterWarehouseOrderByDongGuanAndGuoNei = (
  query?: JdPurchaseEnterWarehouseOrderQuery
): AxiosPromise<JdPurchaseEnterWarehouseOrderVO[]> => {
  return request({
    url: '/dataCheck/jd/purchaseEnterWarehouseOrder/list-by-dongguan-and-guonei',
    method: 'get',
    params: query
  });
};

/**
 * 查询金蝶-采购入库单详细
 * @param id
 */
export const getJdPurchaseEnterWarehouseOrder = (id: string | number): AxiosPromise<JdPurchaseEnterWarehouseOrderVO> => {
  return request({
    url: '/dataCheck/jd/purchaseEnterWarehouseOrder/' + id,
    method: 'get'
  });
};

/**
 * 新增金蝶-采购入库单
 * @param data
 */
export const addJdPurchaseEnterWarehouseOrder = (data: JdPurchaseEnterWarehouseOrderForm) => {
  return request({
    url: '/dataCheck/jd/purchaseEnterWarehouseOrder',
    method: 'post',
    data: data
  });
};

/**
 * 修改金蝶-采购入库单
 * @param data
 */
export const updateJdPurchaseEnterWarehouseOrder = (data: JdPurchaseEnterWarehouseOrderForm) => {
  return request({
    url: '/dataCheck/jd/purchaseEnterWarehouseOrder',
    method: 'put',
    data: data
  });
};

/**
 * 删除金蝶-采购入库单
 * @param id
 */
export const delJdPurchaseEnterWarehouseOrder = (id: string | number | Array<string | number>) => {
  return request({
    url: '/dataCheck/jd/purchaseEnterWarehouseOrder/' + id,
    method: 'delete'
  });
};
